﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WorkingFileManager.MVVM
{
    /// <summary>
    /// These values are used in IWorkingFileOwner implementations to indicate what sort of event is 
    /// happening when we need to retrieve text related to events.
    /// For example, the IWorkingFileOwner might be queried through GetInitialDirectory. This means
    /// "what directory should I default the dialog box to when this happens?" where this is a particual
    /// event like, the user is about to create a new file when there are unsaved changes to the current
    /// one.
    /// </summary>
    public enum FileActionTypes
    {
        SaveBeforeExit,
        SaveBeforeOpen,
        SaveBeforeOpenRecent,
        SaveBeforeNew,
        SaveAs,
        Open
    }

    public interface IWorkingFileOwner
    {
        void CoreSaveFile(string path);
        void CoreOpenFile(string path);
        void CoreNewFile();

        WorkingFileState GetWorkingFileState();

        /// <summary>
        /// Returns the folder that the SaveFileDialog or OpenFileDialog should default to
        /// when that dialog is launched in response to a particular FileActionType. For example,
        /// when the user exits the application via the exit command, and there are unsaved changes,
        /// we may supply a default directory to the SaveFileDialog that is launched if they choose
        /// to save changes. To retreive that, this method will be called with SaveAs as the
        /// parameter.
        /// A simple implementation would be to just return a particular folder no matter which 
        /// FileActionTypes is provided. If null is returned, no value will be passed to the dialog.
        /// </summary>
        string GetInitialDirectory(FileActionTypes fileActionType);

        /// <summary>
        /// Returns a filter string, such as "Text Files (*.txt)|*.txt|All Files (*.*)|*.*", to
        /// pass to a SaveFileDialog or OpenFileDialog when certain actions take place. For example,
        /// if the user exits the application with unsaved changes and no working file, they may elect 
        /// to save changes first. In that case a SaveFileDialog will appear and we must give it a filter.
        /// A simple implementation would be to provide the same filter no matter which
        /// FileActionTypes is provided.
        /// </summary>
        string GetFilter(FileActionTypes fileActionType);

        /// <summary>
        /// Gets the text to display in the popup window when certain things happen.
        /// For example, when the user exits with unsaved changes, we need to display
        /// a message like "Do you want to save changes before exiting?".
        /// 
        /// You do not have to provide an implementation for FileActionTypes.SaveAs and 
        /// FileActionTypes.Open, since those do not produce dialog boxes.
        /// </summary>
        string GetWindowText(FileActionTypes fileActionType);

        /// <summary>
        /// Gets the title to display in the popup window when certain things happen.
        /// For example, when the user exits with unsaved changes, we need to display
        /// a title like "Save changes?".
        ///
        /// You do not have to provide an implementation for FileActionTypes.SaveAs and 
        /// FileActionTypes.Open, since those do not produce dialog boxes.
        /// </summary>
        string GetWindowTitle(FileActionTypes fileActionType);
    }
}
